<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/taglib/cw" prefix="CW"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="<%=basePath%>css/en/edit.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>js/commons/common_edit.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#radio").buttonset();
		$('#insertRoleForm').validate({
			messages : {
				"rolemanager.RoleName" : {
					remote:'该名称已存在'
				}
			},
			rules : {
				"rolemanager.RoleName" : {
				 required : true,
				 rangelength:[1,64],
				 remote: {
						url: "<%=basePath%>/roleAjax/getRoleCount.action", //后台处理程序
						type : "post", //数据发送方式
						dataType : "json", //接受数据格式   
						data : { //要传递的数据
							"RoleName" : function() {
								return $("#RoleName").val();
							}
						}
					}
				},
				"rolemanager.RoleNumber" : {
					number:true,
					required : true,
					rangelength : [ 1, 11 ]
				},
			},
		});
	});
	function __back(){
	 //设置请求的url 
		var _url = "<%=basePath%>/role/findAllRoles.action";
		location.href=_url;
	}
	function __submit(){
	    if($("#insertRoleForm").valid()){
	    	$("#loadingdiv").show();
			document.insertRoleForm.action="<%=basePath%>role/insertRole.action";
			document.insertRoleForm.submit();
		}
	}
</script>
</head>

<body>
<form action="role/insertRole.action" name="insertRoleForm" id="insertRoleForm" method="post" target="mainFrame">
<jsp:include page="../../../common/loadingPage.jsp" />
<div class="pageheader" >
	<!-- 页面标题 -->
	<div class="pagetitle">
		新增角色
	</div>
	<!-- 操作按钮 -->
	<div class="pageheadercontent">
		<div class="toolbar">
			<div class="toolbarright">
				<input class="okbtn" name="_submit" type="button" value="OK" onclick="__submit()">
				<input class="calbtn" name="_back" type="button" value="Cancel" onclick="__back()">
			</div>
		</div>
	</div>
</div>
<div class="writetblbox" style="width: 700px">
	<table class="writetbl" style="width: 100%">
		<tr>
			<th>角色名：</th>
			<td><input name="rolemanager.RoleName" id="RoleName" type="text">
			</td>
			<th>角色排序：</th>
			<td><input name="rolemanager.RoleNumber" type="text" >
			</td>
		</tr>
		<tr>
			<th>状态：</th>
			<td colspan="3">
				<div id="radio">
					<input type="radio" id="radio1" name="rolemanager.Status" checked="checked" value="1"> <label for="radio1">启动</label>
					<input type="radio" id="radio2" name="rolemanager.Status" value="0"> <label for="radio2">停用</label>
				</div>
			</td>
		</tr>
		<tr>
			<th>描述：</th>
			<td colspan="3"><textarea cols="20" name="rolemanager.RoleRemark" rows="4"></textarea>
			</td>
		</tr>
	</table>
</div>
</form>
</body>
</html>
